# pragma once
# include <stdint.h>
# include <atomic>

struct AVCodecContext;
struct AVCodec;
struct AVPacket;
struct SwsContext;
struct AVFrame;
struct AVFrame;

class EncoderFilter;
class _declspec(dllexport) VideoEncoder {
public:
	VideoEncoder(int _width, int _height, int _fps, int _bit_rate);
	uint8_t* getEncodeCodecCtx(size_t* _size) const;
	uint8_t* getExtradata(size_t* _size) const;
	void setFilter(EncoderFilter* _filter);

	void onBGRAData(const uint8_t* _data);

	~VideoEncoder();
private:
	EncoderFilter* m_filter = nullptr;

	AVCodec* m_video_encode_codec = nullptr;
	AVCodecContext* m_video_encode_codec_ctx = nullptr;
	AVPacket* m_video_encode_packet = nullptr;

	AVFrame* m_video_encode_frame = nullptr;
	AVFrame* m_video_screen_frame = nullptr;

	std::atomic_bool m_ready_encode = false;
	
};
